/**
 * 撲克牌
 * @author LuoDong
 * @email luo4521@online.net.tw
 * 2010-2-22 10:34
 */
package com.addcn.texas.view.components
{
	import flash.display.Sprite;
	import flash.utils.getDefinitionByName;
	
	public class Poker extends Sprite	
	{
		private var _top_pos : Object    = { x: 2.5, y: 1.6 };
		private var _bottom_pos : Object = { x: 28,  y: 47.5 };
		private var _suit_pos : Object   = { x: 2.8, y: 14 };
		
		public function Poker() : void
		{
		
		}
		
		/**
		 * 設置撲克牌型
		 * @param	r_arr Array  [牌型,花色] 
		 */
		public function initialize(r_arr : Array ) : void
		{
			var _suit_class : Class;
			var _label_class : Class;
			r_arr[0] = String(r_arr[0]).toUpperCase();
			try{
				_suit_class  =  Class(getDefinitionByName("suit_" + r_arr[1]));
				_label_class = Class(getDefinitionByName("label_" + r_arr[0]));
			}catch (e) {				
				trace("new poker error");				
				return;
			}	
			var  _suit = new _suit_class;			
			var _label1 = new _label_class;
			var _label2 = new _label_class;				
			_suit.x = (this.width - _suit.width) * 0.5;
			_suit.y = (this.height - _suit.height) * 0.5;			
			_label1.x = this.x + 2;
			_label1.y = this.y + 1.6;
			_label2.x = this.width - _label2.width - 2;
			_label2.y = this.height - _label2.height - 1.6;
			if (r_arr[1] == 1 || r_arr[1] == 3) {
				_label1.gotoAndStop(2);
				_label2.gotoAndStop(2);
			}
			this.addChild(_suit);
			this.addChild(_label1);
			this.addChild(_label2);
			
		}	
		
		public function setAlpha(r_num : Number = 0.7 ) : void {
			this.alpha = r_num;
		}
		
	}
	
}
